<?php


	require_once "Controller/photos_controller.php";
	$addPhoto_controller = new photos_controller();

?>
<div class="photoSelector">

	<?php
		$addPhoto_controller->displayPhotosFromFolder();
		$addPhoto_controller->displayPhotosFromFlickr();
	?>

		<input type="submit" value="Ajouter" name="addPhotoToEvent"/>
		
		<input type="hidden" name="imagesArray" value='' id="imagesArray"></input>
		</div>
	</form>
</div>
<script type="text/javascript">

$('div#selectImage').click(function(){
	var selectedImageList = [];
	if(document.getElementById("imagesArray").value != ""){
		selectedImageList = document.getElementById("imagesArray").value.split(',');
	}
	$(this).toggleClass('selected');
	$(this).toggleClass('selectable');
	if($(this).hasClass('selected'))
	{
		selectedImageList.push($(this).children($('a')).attr('src'));
	}
	else
	{
		var indexCurrentImage = selectedImageList.lastIndexOf($(this).children($('a')).attr('src'));
		if (indexCurrentImage >= 0)
		{
			selectedImageList.splice(indexCurrentImage, 1);
		}
	}
	var inputHidden = document.getElementById("imagesArray");
	inputHidden.value = selectedImageList.toString();
});
</script>